package com.myhexin.consumer.loadbalance;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.cluster.LoadBalance;

import java.util.List;

/**
 * @author Jayce
 * @version 1.0.0
 * @date 2021/10/7
 * @desc
 */
@Slf4j
public class UserLoadBalance implements LoadBalance {
    @Override
    public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation) throws RpcException {
        log.info("DemoLoadBalance coming, invokers {}", invokers.get(0).getUrl());
        log.info("DemoLoadBalance coming, url {}", url.toFullString());
        return invokers.get(0);
    }
}
